import { defineStore } from 'pinia'

/**
 * 存储用户信息
 */
export const userStore = defineStore({
    id: 'userStore',
    state: () => ({
        name: ``,
        avatar: ``,
        role: 0,
        userInfo: {}
    }),
    getters: {
        getName: (state) => state.name,
        getRole: (state) => state.name,
        getAvatar: (state) => state.avatar,
        getUserInfo: (state) => state.userInfo,
    },
    actions: {
        setName(name: string) {
            this.name = name;
        },
        setAvatar(avatar: string) {
            this.avatar = avatar;
        },
        setUserInfo(userInfo: object) {
            this.userInfo = userInfo;
        },
        setRole(role: number) {
            this.role = role;
        },
    }
})

export class useUserStore {

}
